use actix_web::{test, App};
use ticker_backend::{routes::init_routes, services::price_service::PriceService};

#[actix_rt::test]
async fn price_endpoint_returns_ok() {
    let price_service = PriceService::new_with_seed(2);
    let app = test::init_service(
        App::new()
            .app_data(actix_web::web::Data::new(price_service))
            .configure(init_routes),
    )
    .await;

    let req = test::TestRequest::get().uri("/api/stocks/AAPL/price").to_request();
    let resp = test::call_service(&app, req).await;
    assert!(resp.status().is_success());

    let body: serde_json::Value = test::read_body_json(resp).await;
    assert!(body.get("data").is_some());
}